<?php
declare(strict_types=1);
namespace Field;

class SysApiStatConst
{
    public const pk='';
    public const index=['Ymd','H','I','Node','Method'];
	public const fields=['Ymd','H','I','Node','Method','Count','UseTime'];
	public const comment=['Ymd'=>'年月日','H'=>'时','I'=>'分','Node'=>'路由','Method'=>'','Count'=>'次数','UseTime'=>'耗时'];
	/*
    * @Field Ymd
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 年月日
    */
    public const Ymd = 'Ymd';
    /*
    * @Field H
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 时
    */
    public const H = 'H';
    /*
    * @Field I
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 分
    */
    public const I = 'I';
    /*
    * @Field Node
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 路由
    */
    public const Node = 'Node';
    /*
    * @Field Method
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Method = 'Method';
    /*
    * @Field Count
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 次数
    */
    public const Count = 'Count';
    /*
    * @Field UseTime
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 耗时
    */
    public const UseTime = 'UseTime';
}

class SysApiStatColumns
{
public  int $Ymd;
   public  int $H;
   public  int $I;
   public  string $Node;
   public  int $Method;
   public  int $Count=0;
   public  int $UseTime=0;
	public function toArray():array
	{
		return [
'Ymd'=>$this->Ymd,
    'H'=>$this->H,
    'I'=>$this->I,
    'Node'=>$this->Node,
    'Method'=>$this->Method,
    'Count'=>$this->Count,
    'UseTime'=>$this->UseTime,        ];
	}
}

class SysApiStatRow
{
	public SysApiStatColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'Ymd' => $this->data->Ymd,
        'H' => $this->data->H,
        'I' => $this->data->I,
        'Node' => $this->data->Node,
        'Method' => $this->data->Method,
        'Count' => $this->data->Count,
        'UseTime' => $this->data->UseTime, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysApiStatColumns();
        isset($data['Ymd']) && $this->data->Ymd = (int)$data['Ymd'];
           isset($data['H']) && $this->data->H = (int)$data['H'];
           isset($data['I']) && $this->data->I = (int)$data['I'];
           isset($data['Node']) && $this->data->Node = (string)$data['Node'];
           isset($data['Method']) && $this->data->Method = (int)$data['Method'];
           isset($data['Count']) && $this->data->Count = (int)$data['Count'];
           isset($data['UseTime']) && $this->data->UseTime = (int)$data['UseTime'];
    }
}
?>